package com.pai4j.netty.server.service.redis;

import lombok.extern.slf4j.Slf4j;


@Slf4j
public class HashRedisService extends AbstractRedisService {

    public static void set(String key, String field, String value, long seconds) {
        executeAndRelease(jedis -> {
            jedis.hset(key, field, value);
            if (seconds > 0) {
                jedis.expire(key, seconds);
            }
        });
    }

    public static String get(String key, String field) {
        return executeAndReleaseWithReturn(jedis -> {
            return jedis.hget(key, field);
        });
    }

    public static void del(String key, String field) {
        executeAndRelease(jedis -> {
            jedis.hdel(key, field);
        });
    }
}
